package com.freestyle.nettychat.chat.dto;


import com.fasterxml.jackson.annotation.JsonIgnore;
import com.freestyle.netty.easynetty.dto.MessageProperties;
import io.netty.channel.ChannelHandlerContext;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by rocklee on 2022/2/4 21:23
 */
public class ChatMessageProperties extends MessageProperties {
  private long timestamp;
  private Map<String,Object> extParams;
  @JsonIgnore
  private transient ChannelHandlerContext ctx;
  public Map<String, Object> getExtParams() {
    return extParams;
  }
  public Object getExtParam(String key){
    return extParams.get(key);
  }
  public void setChatRoom(String chatRoom){
    extParams.put("chatRoom",chatRoom);
  }
  public String getChatRoom(){
    return (String) extParams.get("chatRoom");
  }
  public void setMD5(String md5){
    extParams.put("md5",md5);
  }
  public String getMD5(){
    return (String) extParams.get("md5");
  }
  public void setExtParams(String key,Object val) {
    extParams.put(key,val);
  }
  public void setExtParams(Map<String, Object> extParams) {
    this.extParams = extParams;
  }
  public void setTimestamp(long timestamp){
    this.timestamp=timestamp;
  }
  public long getTimestamp(){
    return timestamp;
  }
  public ChatMessageProperties(Map<String, Object> extParams) {
    this.extParams = extParams;
  }

  public ChannelHandlerContext getCtx() {
    return ctx;
  }

  public void setCtx(ChannelHandlerContext ctx) {
    this.ctx = ctx;
  }

  public ChatMessageProperties(){
    this.extParams=new HashMap<>();
    this.timestamp=new Date().getTime();
  }
  public ChatMessageProperties(String uuid, long id, String sClass, Map<String, Object> extParams) {
    super(uuid, id, sClass);
    this.extParams = extParams;
    this.timestamp=new Date().getTime();
  }
}
